/**
 * Created by Aladin on 2017/3/6.
 */

package com.siia.testing.biz;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.siia.testing.util.HttpRequestUtil;
import org.junit.Assert;
import org.junit.Test;

public class Up_DataBack {
    public static String SERVICE_PREFIX = "http://lwhtest.veiwa.com/webservice/LogisticsApi.asmx?op=";

    @Test
    public void test() {

        String request = getRequest();
        JSONObject requestJson = JSON.parseObject(request);
        JSONObject result = HttpRequestUtil.httpPost(SERVICE_PREFIX + "Up_DataBack", requestJson);
        Assert.assertEquals(getResponse(), result.toJSONString());
    }

    private String getResponse() {
        return "{" +
                "    \"Response\": {" +
                "        \"Header\": {" +
                "           \"CorpCode\":\"1334\"," +
                "            \"Account\":\"LWH\"," +
                "\"Pwd\":\"LWH\"" +
                "        }," +
                "        \"Body\": {" +
                "            \"UserID\": \"123\"," +
                "            \"ClientCode\": \"102101010\"," +
                "            \"strJSONData\": [" +
                "                \"102101010\"," +
                "                \"102101010\"" +
                "            ]," +
                "            \"Mid_ Ohb01\": \"RMD000001\"," +
                "            \"Detail\": [" +
                "                {" +
                "             \"Mid_Ohb03\": \"1\"," +
                "            \"Mid_Ohb04\": \"103010012\"," +
                "            \"Mid_Ohb09\": \"1003\"," +
                "            \"Mid_Ohb091\": \"蓝战储位\"," +
                "            \"Mid_Ohb12\": \"100\"," +
                "            \"Mid_Ohb15\": \"PGS\"" +
                "                }" +
                "            ]" +
                "        }" +
                "    }}";
    }

    private String getRequest() {
        return "{" +
                "    \"Request\":{" +
                "        \"Header\":{" +
                "            \"Account\":\"LWH\"," +
                "\"ErrorCode\":\"00\", " +
                "\"ErrorMsg\":\"\" " +
                "        }," +
                "        \"Body\": {}" +
                "    }" +
                "}";
        }
        }
